// js-cookie是一个操作cookie第三方模块
// get(key) 从cookie中读取值
// set(key,val) 给cookie存储值
// remove(key) 删除cookie中值

import Cookies from 'js-cookie'
const TokenKey = 'hrsaas-ihrm-token'
const TimeKey = 'hrsaas-timestamp-key'

export function getToken() {
  return Cookies.get(TokenKey)
}

export function setToken(token) {
  // 顺便存储时间戳
  setTimeStamp()
  return Cookies.set(TokenKey, token)
}

export function removeToken() {
  return Cookies.remove(TokenKey)
}
// 获取时间戳
export function getTimeStamp() {
  return Cookies.get(TimeKey)
}
// 设置时间戳
export function setTimeStamp() {
  Cookies.set(TimeKey, Date.now())
}
